Scheduler Overview
TBS includes a scheduling feature that consists of two main components. We have the administration screens in TBS, and the actual implementation of the feature in the TBS Backend Service.
The administration screens allow users to setup tasks to be run in a set as a process and schedule them according to a schedule they determine. The screens also allow the user to view the logs and upcoming schedules.
The scheduler feature leverages a few other new features as well. For this release we have created the idea of a distribution list in TBS. Users can now group email addresses into a group for easier emailing. These emails are configured as customers, TBS users, agents, or a custom email address. If the email address changes on a customer, TBS user, or agent they will be automatically updated in the distribution list. This feature is currently only leveraged in the Scheduler feature.
The TBS Backend Service houses the "brains" of the Scheduling feature. It manages the running of processes, creates log entries, and sends reports based on the status of the processes.
Administration Screens
Each process to be scheduled must be setup in the Scheduler admin screens. Before you can create and schedule a process, you must setup the tasks in that process first. Before creating a task, you must first create an Email Template and Distribution Lists. We will run through each of these in order.
Distribution Lists - list of email addresses to whom a communication should be sent.
Email Templates - define the format of an email to be sent from the TBS System.
Tasks - an individual “thing to do” in the system.
Processes and Scheduling - Processes pull everything together (Distribution Lists, Email Templates, Tasks) and allow you to schedule the set as desired.
View Schedule - read only view of all the scheduled processes.
Scheduler Log - provides a full history of all scheduled activity including the result status.
Backend Service
The backend service now has a new Scheduler method that does a few things to enable the running of processes. It operates on a 15 second window. When it starts, it pulls an appsetting that stores that last time it went through a cycle. If it finds anything that was missed the first time through, it sends emails to the Failure Email for those processes to let people know that the process was missed while the backend service was down.
Once it gets into the loop to run, it runs through the SchedulerSchedules table and finds schedules to be run in the current window. It will pick the first task from the process, enter a record in SchedulerLog with an active status, update the SchedulerProcessesTasks record’s status, and the SchedulerProcesses status. It then enters the task into the activity queue.
Next it will look for scheduler logs with an active status. It will take a look into the ActivityQueue to see if the task is running, or if it has been completed and resides in the ActivityLog. If we find it in the ActivityLog, the statuses are updated and we determine if we need to move on to the next task or if we are done. If the task failed, we fail the process, and update the status and send a failure email. If we are done, we send the success email, otherwise we enter a new ActivityQueue record, and repeat.
Run SQL Report
In the activity queue runner, a new type has been introduced to allow us to email sql reports. This process will take a flex report, run the sql, save the results to a csv, run the fix sql if the option is set, run the sql again, save those results to csv, and email them to a user. It is a very straightforward process. The activity queue works from the SchedulerTasks record, if we have multiple reports in one task, we run each separately, if one fails, we send a failure email to the task failure distribution list, but we keep going. Once all reports have been run, we look at the “Email Report with No Rows option” and the number of reports we have attached, and determine if we should email the report or not. If we determine to email the report, we send it to the Report Distribution list on the SchedulerTask.
It should be noted that to be eligible for running a report, all parameters tied to it must be either optional or have a default value.
Limitations
Only Scheduled Reports are currently supported as a task type. Many more schedule processes will be made available in future releases.